package com.showde.shoppingmall.business.logic;

import org.json.JSONObject;

import com.kim.net.NetEntity;
import com.showde.shoppingmall.business.InformationFetchBusiness;
import com.showde.shoppingmall.business.InformationFetchBusiness.INFOMATION_TYPE;
import com.showde.shoppingmall.business.NetCallbackImplBase.Notify;

public class InformationFetchLogic {

	public static final void fetchGJPInfo(INFOMATION_TYPE type,
			final UICallbackInterface uiCallbackInterface) {
		InformationFetchBusiness business = new InformationFetchBusiness(type,
				new Notify() {

					@Override
					public void notifyNetCallback(NetEntity netEntity) {

						try {
							JSONObject jsonObject = netEntity.result;
							String returnCode = jsonObject
									.getString("ReturnCode");
							if ("0".equals(returnCode)) {
								String info = jsonObject.getString("info");
								CallbackData data = new CallbackData();
								data.data = info;
								uiCallbackInterface.onSuccess(data);
								return;
							}
						} catch (Exception e) {
							uiCallbackInterface.onError(e.getMessage());
						}
						uiCallbackInterface.onError("unkown error.");
					}

					@Override
					public void notifyError(int httpResponseCode,
							String errorMsg) {

					}
				});
		business.doBusiness();
	}
}
